package com.example.quarkus.service;

import com.example.quarkus.entity.Org;
import com.example.quarkus.exception.BusinessException;
import com.example.quarkus.mapper.OrgMapper;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
import org.jboss.logging.Logger;


@ApplicationScoped
public class OrgService {
    private static final Logger LOGGER = Logger.getLogger(OrgService.class.getName());
    @Inject
    OrgMapper orgMapper;

    public Org getOrgById(Integer id) {
        Org org = orgMapper.selectByPrimaryKey(id);
        if (org == null){
            LOGGER.info("There is no org data in mysql with id=" + id);
            throw new BusinessException("No Org with id=" + id);
        }
        return org;
    }
}
